
#include <iostream>

using namespace std;
/**
c++函数模板的例子
https://blog.csdn.net/lms1008611/article/details/81985815
*/
template <typename T>
void Swap(T& a, T& b)
{
    T tmp = a;
    a = b;
    b = tmp;
}

int main()
{
    int a = 10;
    int b = 20;
    Swap(a, b);	//自动推到调用
    //Swap<int>(a, b);//显示指定调用
    cout << "a = " << a << endl;
    cout << "b = " << b << endl;

    float c = 12.3;
    float d = 23.4;

    //Swap(c, d); //自动推到调用
    Swap<float>(c, d); //显示指定调用
    cout << "c = " << c << endl;
    cout << "d = " << d << endl;
    system("read");
    return 0;
}